using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
class Program
{
    static void Main()
    {
        string concatnumber = "";
        int k = int.Parse(Console.ReadLine());
        int n = int.Parse(Console.ReadLine());
        for (int i = 0; i < n; i++)
        {
            int currentnumber = int.Parse(Console.ReadLine());
            string binary = Convert.ToString(currentnumber, 2);
 
            concatnumber = concatnumber + binary;
        }
 
 
        //string concatnumber = "10101010101010101010";
        //int k = 1;
 
        int counter = 0;
        int result = 0;
 
        while (concatnumber.Length != 0)
        {
            string lastchar = concatnumber.Substring(concatnumber.Length - 1, 1);
            concatnumber = concatnumber.Remove(concatnumber.Length - 1, 1);
            string beforelastchar;
 
            if (concatnumber.Length == 0)
            {
                beforelastchar = "";
            }
            else
            {
                beforelastchar = concatnumber.Substring(concatnumber.Length - 1, 1);
            }
             
 
            if (lastchar == beforelastchar)
            {
                counter++;
            }
            else
            {
 
                    if (counter == k - 1)
                    {
                        result++;
                        counter = 0;
                    }
                    else
                    {
                        counter = 0;
                    }
                 
                 
            }
        }
 
            Console.WriteLine(result);
                            
    }
}